package com.mashibing.controller;

import com.msb.framework.redis.RedisClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @ClassName:TestController
 * @author:[开发者名称]
 * @Description:[类的功能描述]
 * @Date:2025/9/14/16:26
 * @Version:1.0
 */
@RestController

public class TestController {
    @Autowired
    private RedisClient redisClient ;
//    @Autowired
//    RedisTemplate<String,Object> redisTemplate;
    // 写测试   hash结构
    @PostMapping("/test/set/{key}")
    public String set(@PathVariable String key, @RequestBody Map map){
          redisClient.hSet(key,map);//添加哈希数据类型
//        redisTemplate.opsForHash().putAll(key,map);
        return "ok";
    }
    // 读测试
    @GetMapping("/test/get/{key}")
    public Map get(@PathVariable String key){
        Map<String, Object> result = redisClient.hGetAll(key);
        //Map<Object, Object> result = redisTemplate.opsForHash().entries(key);
        // 获取 hash的value String value = hGet(key,map的key)
        return result;
    }

}
